package com.gcpproxy.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class ChatCompletionRequest {
    
    private String model;
    
    @JsonProperty("max_tokens")
    private Integer maxTokens;
    
    private Double temperature;
    
    private Boolean stream;
    
    @JsonProperty("response_format")
    private Map<String, Object> responseFormat;
    
    private List<ChatMessage> messages;

    private List<Safety> safetySettings ;
    private GenerationConfig generationConfig;  // 添加这个字段


    @Data
    public static class GenerationConfig {
        public List<String> responseModalities;
    }

    @Data
    public static class  Safety{
        public String category;
        public String threshold;

        public Safety( String category , String threshold ) {
            this.category = category;
            this.threshold = threshold;
        }
    }
    public int getMaxTokensOrDefault() {
        return maxTokens != null ? maxTokens : 65536;//gemini 最大65536
    }
    
    public double getTemperatureOrDefault() {
        return temperature != null ? temperature : 0.7;
    }
    
    public boolean isStreamOrDefault() {
        return stream != null && stream;
    }
}

